import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2024-03-24
 * Time: 10:26
 */

class Solution {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> list = new ArrayList<>();
        list.add(1);
        ret.add(list);
        for (int i = 1; i < numRows; i++) {
            List<Integer> curRow = new ArrayList<>();
            curRow.add(1);
            for (int j = 1; j < i; j++) {
                List<Integer> preRow = ret.get(i-1);
                int val = preRow.get(j) + preRow.get(j-1);
                curRow.add(val);
            }
            //斜角的地方也是1
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }
}
public class Test {
    //简单洗牌算法的实现
    public static final String[] SUITS = {"♥", "♠", "♣", "♦"};


    //1.首先要有牌,生成我的52张牌
    public static List<Card> buyCard(List<Card> cards) {

        for (int i = 0; i < SUITS.length; i++) {
            for (int j = 1; j <= 13; j++) {
                Card card = new Card(SUITS[i],j);
                cards.add(card);
            }
        }
        return cards;
    }
    //2.洗牌
    public static void shuffle(List<Card> cards) {
        Random random = new Random();
        for (int i = cards.size()-1; i > 0; i--) {
            int j = random.nextInt(i);
                //交换牌
                Card tmp = cards.get(i);
                cards.set(i,cards.get(j));
                cards.set(j,tmp);

        }
        System.out.print(cards);
    }
    //3.3个人,每个人轮流抽牌5张


    public static void main(String[] args) {
        List<Card> cards = new ArrayList<>();
        System.out.println(buyCard(cards));
        System.out.println("洗牌后: ");
        shuffle(cards);
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        List<List<Card>> hand = new ArrayList<>();
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);
        //实现3个人,轮流揭5张牌
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                //揭牌
                Card card = cards.remove(0);
                //此时牌到了哪个list
                hand.get(j).add(card);
            }
        }
        System.out.println("第一个人的牌: ");
        System.out.println(hand1);
        System.out.println("第二个人的牌: ");
        System.out.println(hand2);
        System.out.println("第三个人的牌: ");
        System.out.println(hand3);
        System.out.println("剩下的牌: ");
        System.out.println(cards);
    }
}
